#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MOD = 100003;

LL qmul(LL a, LL b, LL p)
{
	LL ans = 0;
	while(b)
	{
		if(b & 1) ans = (ans + a) % p;
		a = (a + a) % p;
		b >>= 1;
	}
	return ans;
}

LL qpow(LL a, LL b, LL p)
{
	LL ans = 1;
	while(b)
	{
		if(b & 1) ans = ans * a % p;
		a = a * a % p;
		b >>= 1;
	}
	return ans;
}

int main()
{
	LL m, n; cin >> m >> n;
	LL ans = qpow(m, n, MOD) - qmul(m, qpow(m - 1, n - 1, MOD), MOD);
	cout << (ans % MOD + MOD) % MOD << endl;
 	return 0;
}